package com.yuqiaotech.dbpro.filter.transaction;


public class StatementInfo implements Cloneable {
	
	public static final int BEGIN       = 0;
	public static final int UNCOMMITTED = 1;
	public static final int COMMITTED   = 2;
	public static final int ROLLBACKED  = 3;
	
	private Object[] params;
	
	// 该状态可能会被事务修改，当事务提交或回滚时
	int status;
	
	private String sql;
	private long transactionId;
	private long beforeExecuteTime;
	private long afterExecuteTime;
	private long commitTime;
	private long rollbackTime;
	
	public StatementInfo copyDeep() {
		StatementInfo result = null;
		try {
			result = (StatementInfo)this.clone();
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		
		// 拷贝参数
		if (null != params && params.length > 0) {
			result.params = new Object[params.length];
			System.arraycopy(params, 0, result.params, 0, params.length);
		}
		
		return result;
	}
	
	public Object[] getParams() {
		return params;
	}
	
	public void setParams(Object[] params) {
		this.params = params;
	}
	
	public String getSql() {
		return sql;
	}
	
	public void setSql(String sql) {
		this.sql = sql;
	}
	
	public long getBeforeExecuteTime() {
		return beforeExecuteTime;
	}
	
	public void setBeforeExecuteTime(long beforeExecuteTime) {
		this.beforeExecuteTime = beforeExecuteTime;
	}
	
	public long getAfterExecuteTime() {
		return afterExecuteTime;
	}
	
	public void setAfterExecuteTime(long afterExecuteTime) {
		this.afterExecuteTime = afterExecuteTime;
	}
	
	public long getCommitTime() {
		return commitTime;
	}
	
	public void setCommitTime(long commitTime) {
		this.commitTime = commitTime;
	}
	
	public long getRollbackTime() {
		return rollbackTime;
	}
	
	public void setRollbackTime(long rollbackTime) {
		this.rollbackTime = rollbackTime;
	}
	
	public int getStatus() {
		return status;
	}

	public long getTransactionId() {
		return transactionId;
	}

	public void setTransactionId(long transactionId) {
		this.transactionId = transactionId;
	}
	
	
	
}
